Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor + new account sync metrics + isolating health status inside folder admin-panel > health-status #10314

Merged
merged 18 commits into from
Feb 21, 2025

Conversation

ehconitin
Copy link
Contributor

@ehconitin ehconitin commented Feb 18, 2025

Copy link
Contributor

@greptile-apps greptile-apps bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

PR Summary

This PR introduces significant changes to the health status monitoring system, focusing on account synchronization and component organization.

  • Replaces message sync with comprehensive account sync monitoring in /packages/twenty-server/src/engine/core-modules/health/indicators/account-sync.health.ts, adding calendar sync metrics
  • Reorganizes health status components into dedicated /health-status folder structure for better code organization
  • Simplifies SystemHealth DTO in /packages/twenty-server/src/engine/core-modules/admin-panel/dtos/system-health.dto.ts to use direct status enums
  • Adds calendar sync health monitoring with 20% failure rate threshold and timeout handling
  • Integrates health monitoring into calendar event import system via HealthModule in related modules

Note: The PR description references issues about keyboard shortcuts and soft focus mode, but the actual changes are unrelated to those issues.

39 file(s) reviewed, 14 comment(s)
Edit PR Review Bot Settings | Greptile

the service is down
</StyledErrorMessage>
) : (
<StyledDetailsContainer>{formattedDetails}</StyledDetailsContainer>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: formattedDetails could be null here. Consider adding a fallback message when no details are available.

details,
title,
}: {
details: Record<string, any> | null;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Using Record<string, any> is too permissive. Consider creating a specific type for the details object structure

Comment on lines 151 to 153
accountSyncHealth.isHealthy.mockRejectedValue(
new Error(HEALTH_ERROR_MESSAGES.MESSAGE_SYNC_CHECK_FAILED),
);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

logic: Using MESSAGE_SYNC_CHECK_FAILED error for accountSync is inconsistent with the service name change. Should use a new ACCOUNT_SYNC_CHECK_FAILED error message.

Comment on lines +141 to +147
const currentCounter =
await this.cacheStorage.get<AccountSyncJobByStatusCounter>(cacheKey);

const updatedCounter = {
...(currentCounter || {}),
[status]: (currentCounter?.[status] || 0) + increment,
};
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

style: Duplicate code pattern between message and calendar sync counters. Consider extracting to a shared method to reduce duplication.

const services = [
{
id: 'DATABASE',
name: 'Database Status',
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also use this in breadcrumb?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I removed this from the front, and added it as a const in the back itself to have single source of truth, may be you want to check the descriptions, I just have them as a generic sentence as of now

: AdminPanelHealthServiceStatus.OUTAGE;
}

private transformServiceDetails(details: any) {
Copy link
Contributor Author

@ehconitin ehconitin Feb 21, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@FelixMalfait, I am keeping this asany for now, as there is no proper structure to it yet!
To be improved upon in upcoming PRs

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok to do it in a followup PR 👍

<>
{errorMessages.length > 0 && (
<StyledErrorMessage>
{`${errorMessages.join(' and ')} ${errorMessages.length > 1 ? 'are' : 'is'} not available because the service is down`}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should use t`` for translatable strings

{!isMessageSyncDown && parsedDetails.messageSync?.details && (
<SettingsAdminHealthAccountSyncCountersTable
details={parsedDetails.messageSync.details}
title="Message Sync Status"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Other example of translatable string

@FelixMalfait FelixMalfait merged commit c46f784 into twentyhq:main Feb 21, 2025
45 checks passed
Copy link
Contributor

Thanks @ehconitin for your contribution!
This marks your 104th PR on the repo. You're top 1% of all our contributors 🎉
See contributor page - Share on LinkedIn - Share on Twitter

Contributions

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Optimize Health Status Queries and Remove Redundant Data Fetching
2 participants